package br.com.prontuario.dao.unitario.impl;

import java.util.List;

import org.hibernate.Query;
import org.springframework.stereotype.Repository;

import br.com.prontuario.dao.generico.DaoGenerico;
import br.com.prontuario.dao.unitario.contract.TelefoneDaoContract;
import br.com.prontuario.entidade.Telefone;

@Repository("daoTelefone")
public class TelefoneDao extends DaoGenerico<Telefone> implements TelefoneDaoContract {

	private static final long serialVersionUID = 1L;

	@Override
	@SuppressWarnings("unchecked")
	public List<Telefone> buscarTelefonesProprietario(Long idProprietario) throws Exception {
		StringBuilder sqlTotal = new StringBuilder();
		sqlTotal.append(" SELECT e from Telefone e");
		sqlTotal.append(" where e.proprietario.id = " + idProprietario);
		
		Query query = getSession().createQuery(sqlTotal.toString());
		return query.list();
	}

}
